package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import service.UserInfoService;
//用户注册

@WebServlet(urlPatterns = {"/UserRegisterServlet"})
public class UserRegister extends HttpServlet {

    UserInfoService userInfoService = new UserInfoService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取参数
        String userName = req.getParameter("userName");
        String passWord = req.getParameter("passWord");
        String nickName = req.getParameter("nickName");
        String age = req.getParameter("age");
        String sex = req.getParameter("sex");
        //用户注册
        this.userInfoService.UserRegister(userName, passWord, nickName, Integer.parseInt(age), sex);
        //注册成功
        req.getRequestDispatcher("user-register-success.jsp").forward(req, resp);

    }

}
